package com.example.farmeri.adapter;

import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

/**
 * Create by weiqishan on 2020/4/6.
 * 配置适配器
 */
public class UserManagerViewAdapter extends RecyclerView.Adapter{
    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        return null;
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {

    }

    @Override
    public int getItemCount() {
        return 0;
    }

    //Context context;
    //Integer screeWidth;
    //Integer layout;
    //
    //OnExtraClickListener onExtraClickListener;
    //
    //public UserManagerViewAdapter(Context context, int layout, int screeWidth) {
    //    this.context = context;
    //    this.layout = layout;
    //    this.screeWidth = screeWidth;
    //}
    //
    //@NonNull
    //@Override
    //public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
    //    LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
    //    View itemView = inflater.inflate(layout,viewGroup,false);
    //    return new MyViewHolder(itemView);
    //}
    //
    //@SuppressLint("ClickableViewAccessibility")
    //@Override
    //public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
    //    MyViewHolder MyViewHolder = (MyViewHolder) viewHolder;
    //    MyViewHolder.layoutShow.setMinWidth(screeWidth);
    //    User user = new User();
    //    MyViewHolder.niceName.setText(user.getNickName()+i);
    //    MyViewHolder.credit.setText(String.valueOf(user.getCredit()));
    //    //设置滑动效果
    //    MyViewHolder.container.setOnTouchListener(new View.OnTouchListener() {
    //        @Override
    //        public boolean onTouch(View v, MotionEvent event) {
    //            //用户行为
    //            int action = event.getActionMasked();
    //            switch(action){
    //                case MotionEvent.ACTION_UP:
    //                    //操作界面的宽度
    //                    int hideLayoutWidth = MyViewHolder.layoutHide.getWidth();
    //                    //滑动的距离
    //                    int scrollX = MyViewHolder.container.getScrollX();
    //                    //滑动距离大于操作界面的一半时显示操作界面
    //                    if (scrollX > hideLayoutWidth/2){
    //                        MyViewHolder.container.smoothScrollTo(hideLayoutWidth,0);
    //                    }else {
    //                        MyViewHolder.container.smoothScrollTo(0,0);
    //                    }
    //                    return true;
    //            }
    //            return false;
    //        }
    //    });
    //    MyViewHolder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    //        @Override
    //        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    //            //获取当前的item位置
    //            int position = MyViewHolder.getAdapterPosition();
    //            if (isChecked){
    //                onExtraClickListener.onChecked(position);
    //            }else {
    //                onExtraClickListener.onUnChecked(position);
    //            }
    //
    //        }
    //    });
    //    //设置点击界面勾选
    //    MyViewHolder.layoutShow.setOnClickListener(new View.OnClickListener() {
    //        @Override
    //        public void onClick(View v) {
    //            if (MyViewHolder.container.getScrollX() > 0){
    //                MyViewHolder.container.smoothScrollTo(0,0);
    //                return;
    //            }
    //            MyViewHolder.checkBox.setChecked(!MyViewHolder.checkBox.isChecked());
    //        }
    //    });
    //    //点击锁定
    //    MyViewHolder.lock.setOnClickListener(new View.OnClickListener() {
    //        @Override
    //        public void onClick(View v) {
    //            if (onExtraClickListener != null){
    //                onExtraClickListener.onLockClick(v, MyViewHolder.getAdapterPosition());
    //            }
    //
    //        }
    //    });
    //    //点击编辑
    //    MyViewHolder.edit.setOnClickListener(new View.OnClickListener() {
    //        @Override
    //        public void onClick(View v) {
    //            if (onExtraClickListener != null) {
    //                onExtraClickListener.onEditClick(v,MyViewHolder.getAdapterPosition());
    //            }
    //
    //        }
    //    });
    //    //点击删除
    //    MyViewHolder.del.setOnClickListener(new View.OnClickListener() {
    //        @Override
    //        public void onClick(View v) {
    //            if (onExtraClickListener != null) {
    //                onExtraClickListener.onDelClick(v,MyViewHolder.getAdapterPosition());
    //            }
    //        }
    //    });
    //}
    //
    //@Override
    //public int getItemCount() {
    //    return 20;
    //}
    //
    //public void setOnExtraClickListener(OnExtraClickListener onExtraClickListener) {
    //    this.onExtraClickListener = onExtraClickListener;
    //}
    //
    //public static class MyViewHolder extends RecyclerView.ViewHolder {
    //
    //    HorizontalScrollView container; //显示界面与操作界面的容器
    //    ConstraintLayout layoutShow;    //显示界面
    //    LinearLayout layoutHide;    //操作界面
    //    CheckBox checkBox;    //复选框
    //    TextView lock;
    //    TextView del;
    //    TextView edit;
    //    TextView niceName;   //用户昵称
    //    TextView identity;   //用户身份
    //    TextView type;   //用户类型
    //    TextView credit;   //用户信誉积分
    //
    //
    //    public MyViewHolder(@NonNull View itemView) {
    //        super(itemView);
    //        container = itemView.findViewById(R.id.item_user_manager_container);
    //        layoutShow = itemView.findViewById(R.id.item_user_manager_layout_show);
    //        layoutHide = itemView.findViewById(R.id.item_user_manager_layout_hide);
    //        checkBox = itemView.findViewById(R.id.item_user_manager_checkBox);
    //        lock = itemView.findViewById(R.id.item_user_manager_lock);
    //        edit = itemView.findViewById(R.id.item_user_manager_edit);
    //        del = itemView.findViewById(R.id.item_user_manager_del);
    //        niceName = itemView.findViewById(R.id.item_user_manager_nickname);
    //        identity = itemView.findViewById(R.id.item_user_manager_identity);
    //        type = itemView.findViewById(R.id.item_user_manager_user_type);
    //        credit = itemView.findViewById(R.id.item_user_manager_credit);
    //    }
    //}
}